#!/bin/bash
update_file=core.zip
docker_dir=/docker-file-PROD/wethink-core

prod_version_log=$docker_dir/prod_version.log
prod_core_version=`cat $prod_version_log`
prod_docker_domain=xxx


prod_docker_pull(){
    #解压到docker目录
    unzip -oq /app/update/aldi/$update_file -d /docker-file-PROD/wethink-core/wethink-core
    cd $docker_dir
    #覆盖配置文件,请确认这2个文件是否存在
    \cp -r application.yml wethink-core/WEB-INF/classes/config/
    \cp -r SchedulerConfigCore.yml wethink-core/WEB-INF/classes/
    #删除多余的文件
    rm -rf $docker_dir/wethink-core/WEB-INF/lib/mail-1.4.jar
    rm -rf $docker_dir/wethink-core.tgz
    #覆盖 
    cd $docker_dir/wethink-core
    tar -zcf wethink-core.tgz *
    mv /docker-file-PROD/wethink-core/wethink-core/wethink-core.tgz /docker-file-PROD/wethink-core/
    #docker 打包上传到对应镜像仓库
    cd $$docker_dir
    docker build -t $prod_docker_domain/wethink-core-tomcat:8.5v"$prod_core_version" -f DockerFile .
    docker push $prod_docker_domain/wethink-core-tomcat:8.5v"$prod_core_version"
    #每次+1
    echo $prod_core_version
    let  $prod_core_version+=1;echo $prod_core_version >$prod_version_log
}


prod_docker_pull

